package com.ctshk.sapp.train.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.train.dto.*;
import com.ctshk.rpc.train.req.TrainIdPriceQueryReq;
import com.ctshk.rpc.train.req.TrainStationIdQueryReq;
import com.ctshk.rpc.train.req.TrainTimeQueryReq;
import com.ctshk.rpc.train.service.ITrainApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(value="资源中心-阿里云火车API", tags="资源中心-阿里云火车API")
@RestController
@RequestMapping("/train")
public class TrainApiController extends BaseController {

    @DubboReference
    private ITrainApiService trainService;


    @ApiOperation(value = "查询火车车次时间", notes = "查询火车车次时间")
    @OperationLogAnnotation(operModul = OperationLogModel.GUIDE, operType = OperationLogType.QUERY, operTitle = "查询火车车次时间", operDesc = "查询火车车次时间")
    @PostMapping("/trainIdTime")
    public Result<TrainTimeQueryDTO> getTrainIdTime(@RequestBody @Valid TrainTimeQueryReq req) {
        return trainService.getTrainIdTime(req);
    }


    @ApiOperation(value = "查询火车车次列表", notes = "查询火车车次列表")
    @OperationLogAnnotation(operModul = OperationLogModel.GUIDE, operType = OperationLogType.QUERY, operTitle = "查询火车车次列表", operDesc = "查询火车车次列表")
    @PostMapping("/trainStationIdList")
    public Result<List<TrainTimeDTO>> getTrainStationIdList(@RequestBody @Valid TrainStationIdQueryReq req) {
        return Result.success(trainService.getTrainStationIdList(req));
    }

    @ApiOperation(value = "查询火车车站标签", notes = "查询火车车站标签")
    @OperationLogAnnotation(operModul = OperationLogModel.GUIDE, operType = OperationLogType.QUERY, operTitle = "查询火车车站标签", operDesc = "查询火车车站标签")
    @GetMapping("/trainStationLabel")
    public Result<List<TrainStationLabelDTO>> getTrainStationLabel() {
        return Result.success(trainService.getTrainStationLabel());
    }

    @ApiOperation(value = "查询火车车次票价", notes = "查询火车车次票价")
    @OperationLogAnnotation(operModul = OperationLogModel.GUIDE, operType = OperationLogType.QUERY, operTitle = "查询火车车次票价", operDesc = "查询火车车次票价")
    @PostMapping("/trainIdPrice")
    public Result<TrainIdPriceDTO> getTrainIdPrice(@RequestBody @Valid TrainIdPriceQueryReq req) {
        return Result.success(trainService.getTrainIdPrice(req));
    }





}
